#ifndef RECIVEDATA_H
#define RECIVEDATA_H

#include<QObject>
#include"agreement.h"
#include"Buffer.h"
#include<QStringList>
#include<mutex>

#define maxReadChar 4096

class ReceiveData:public QObject
{
    Q_OBJECT
private:
    Buffer  accumulatedBuffer;
    ReceiveData(const ReceiveData&) = delete;
    ReceiveData &operator = (const ReceiveData&) = delete;

    QStringList FriendList;
    std::mutex friendMutex;
    int jj = 0;

public:
    bool stopFlag = false;

    ReceiveData();

    void reviveData();

    static ReceiveData &getInstance();

    void handleEvent(Buffer &buff);
    void handleEvent(const CloudDrive::Packet &ptk);


signals:
    void RegistSignal(CloudDrive::MessageReturn);

    void LoginSignal(CloudDrive::MessageReturn);

    void RefreshSignal(QStringList);

    void AddFriendSignal(CloudDrive::MessageReturn);

    void CallBackFriendSignael(std::string);

    void RemeveFriend(CloudDrive::MessageReturn);

    void RemeveFriendREQ(CloudDrive::MessageReturn,std::string);

    void SendMsgShow(std::string FriendName,std::string msg);

    void RefreshFileSignal(CloudDrive::MesBackFile);

    void CreatNewFileSignal(CloudDrive::MessageReturn);

    void DeleteFileSignal(CloudDrive::MessageReturn);

    void FileACKMsg(CloudDrive::FileInfo);

    void DownFile(std::vector<uint8_t>);
};

#endif // RECIVEDATA_H
